﻿using System;
using System.Configuration;
using System.Data.SqlClient;

namespace Web {

  public partial class System_Data : System.Web.UI.Page {

    private string CONN_STRING_BEETLE = ConfigurationManager.ConnectionStrings["connStringBeetle"].ConnectionString;

    protected void Page_Load(object sender, EventArgs e) {

      if (!IsPostBack) {

        SqlConnection conn = null;
        
        using (conn = new SqlConnection(CONN_STRING_BEETLE)) {
          conn.Open();
          
          // 获取数据库架构信息
          gvSchema.DataSource = conn.GetSchema();
          gvSchema.DataBind();

          // 获取所有表
          gvTables.DataSource = conn.GetSchema(SqlClientMetaDataCollectionNames.Tables);
          gvTables.DataBind();

          // 获取所有存储过程
          gvProcedures.DataSource = conn.GetSchema(SqlClientMetaDataCollectionNames.Procedures);
          gvProcedures.DataBind();

          conn.Close();
        }
      }
    }
  }
}